<%--
  Created by IntelliJ IDEA.
  User: 95344
  Date: 2025/11/7
  Time: 09:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>编辑员工信息</title>
    <style>
        body { font-family: sans-serif; margin: 20px; }
        .form-container { max-width: 600px; margin: 0 auto; }
        .form-item { margin-bottom: 15px; }
        label {
            display: inline-block;
            width: 120px;
            font-weight: bold;
            vertical-align: top;
        }
        input[type="text"],
        input[type="password"],
        input[type="date"],
        select {
            width: 300px;
            padding: 8px;
            box-sizing: border-box;
        }
        .btn {
            padding: 10px 20px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            margin-right: 10px;
        }
        .btn:hover { background-color: #0056b3; }
        .btn-cancel { background-color: #6c757d; }
        .btn-cancel:hover { background-color: #5a6268; }
        .info-display { color: #666; }
    </style>
</head>
<body>
<div class="form-container">
    <h1>编辑员工信息</h1>
    <form action="${pageContext.request.contextPath}/employee" method="post" enctype="multipart/form-data">

        <input type="hidden" name="method" value="update">
        <input type="hidden" name="id" value="${employee.id}">
        <input type="hidden" name="oldImage" value="${employee.image}">

        <div class="form-item">
            <label>员工姓名:</label>
            <input type="text" name="empName" value="${employee.name}" required>
        </div>

        <div class="form-item">
            <label>登录密码:</label>
            <input type="password" name="password" placeholder="不修改请留空">
        </div>

        <div class="form-item">
            <label>出生日期:</label>
            <input type="date" name="birthday" value="${employee.birthday}" required>
        </div>

        <div class="form-item">
            <label>工资:</label>
            <input type="text" name="salary" value="${employee.salary}" required>
        </div>

        <div class="form-item">
            <label>所属部门:</label>
            <select name="depId" required>
                <option value="1" ${employee.depId == 1 ? 'selected' : ''}>技术部</option>
                <option value="2" ${employee.depId == 2 ? 'selected' : ''}>市场部</option>
                <option value="3" ${employee.depId == 3 ? 'selected' : ''}>人事部</option>
                <option value="4" ${employee.depId == 4 ? 'selected' : ''}>财务部</option>
            </select>
        </div>

        <div class="form-item">
            <label>员工状态:</label>
            <select name="start" required>
                <option value="0" ${employee.start == 0 ? 'selected' : ''}>在职</option>
                <option value="1" ${employee.start == 1 ? 'selected' : ''}>离职</option>
            </select>
        </div>

        <div class="form-item">
            <label>当前头像:</label>
            <div>
                <img src="${pageContext.request.contextPath}${employee.image}" alt="员工头像" style="width: 100px; height: 100px; object-fit: cover; border: 1px solid #ddd;">
            </div>
        </div>

        <div class="form-item">
            <label>更换头像:</label>
            <input type="file" name="imgUrl" accept="image/*">
        </div>

        <div class="form-item">
            <label>创建时间:</label>
            <span class="info-display">${employee.createTime}</span>
        </div>

        <div class="form-item">
            <label>最后更新时间:</label>
            <span class="info-display">${employee.updateTime}</span>
        </div>

        <div class="form-item">
            <label></label>
            <input type="submit" class="btn" value="保存修改">
            <a href="${pageContext.request.contextPath}/emp.jsp" class="btn btn-cancel">取消</a>
        </div>
    </form>
</div>
</body>
</html>
